package com.zlq.cn.controller.sign.exam;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zlq.cn.annotations.UnPrintResult;
import com.zlq.cn.api.SignApiResult;
import com.zlq.cn.controller.BaseController;
import com.zlq.cn.entity.ExamAnswers;
import com.zlq.cn.entity.ExamQuestions;
import com.zlq.cn.entity.ExamTestPaper;
import com.zlq.cn.service.exam.ExamAnswersService;
import com.zlq.cn.service.exam.ExamTestPaperService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * 考试题库-试卷
 *
 * @author zhoucl
 * @since 2024-04-10
 */
@Api(tags = "考试题库-试卷")
@RestController
@RequestMapping("/exam/test/paper")
public class ExamTestPaperController extends BaseController {

    @Resource
    private ExamTestPaperService examTestPaperService;

    @ApiOperation("试卷列表")
    @PostMapping("/page")
    public SignApiResult<Page<ExamTestPaper>> page(@RequestBody ExamTestPaper examTestPaper) {
        return SignApiResult.resultSuccess(examTestPaperService.page(super.<ExamTestPaper>getPage(), examTestPaper));
    }

    @ApiOperation("试卷详情")
    @PostMapping("/get")
    public SignApiResult<ExamTestPaper> get(@RequestBody ExamTestPaper examTestPaper) {
        return SignApiResult.resultSuccess(examTestPaperService.get(examTestPaper));
    }

    @ApiOperation("删除试卷")
    @PostMapping("/delete")
    public SignApiResult<Boolean> delete(@RequestBody ExamTestPaper examTestPaper) {
        return SignApiResult.resultSuccess(examTestPaperService.delete(examTestPaper));
    }

    @UnPrintResult
    @ApiOperation("导入试卷")
    @PostMapping("/import")
    public SignApiResult<Integer> importTestPaper(@RequestParam("file") MultipartFile file, String title) {
        return SignApiResult.resultSuccess(examTestPaperService.importTestPaper(file, title));
    }
}

